// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
  env:"cjw12138-4gb2o61v4b4636ac"
})

const db = cloud.database();

// 云函数入口函数
exports.main = async (event, context) => {
  const openid = cloud.getWXContext().OPENID
  var {obj} = event;
  obj.openid = openid;
  // obj.postTime = Date.now();
  // var date = new Date();
  // var month = date.getMonth()+1;
  // var day = date.getDay();
  // var pt = month + "月" + day + "日";
  // obj.postTime2 = pt;
  // console.log(obj)
  db.collection("articles").add({
    data:obj
  })
  return true
}